home *** CD-ROM | disk | FTP | other *** search
/ Game Programming in C++ - Start to Finish / GameProgrammingS.iso / Peon / PeonSDK-Win32-1.0.0.exe / {app} / PeonMain / include / SceneTexture.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-11-25  |  2.5 KB  |  94 lines

  1.  
  2.  
  3. #ifndef __SCENETEXTURE_H_
  4. #define __SCENETEXTURE_H_
  5. /*
  6. Peon - Win32 Games Programming Library
  7. Copyright (C) 2002-2005 Erik Yuzwa
  8.  
  9. This library is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU Library General Public
  11. License as published by the Free Software Foundation; either
  12. version 2 of the License, or (at your option) any later version.
  13.  
  14. This library is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. Library General Public License for more details.
  18.  
  19. You should have received a copy of the GNU Library General Public
  20. License along with this library; if not, write to the Free
  21. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  22.  
  23. Erik Yuzwa
  24. peon AT wazooinc DOT com
  25. */
  26.  
  27.  
  28. #include "IUnknown.h"
  29.  
  30. #include <SDL_image.h>
  31.  
  32.  
  33. namespace peon
  34. {
  35.     /**
  36.     * This object encapsulates the "magic" behind loading and manipulating
  37.     * texture data. Right now, it's a very simplistic container but 
  38.     * to start with, that's all we need. It can handle any image format
  39.     * supported by the SDL_Image helper library. For the most part, I usually
  40.     * try to stick with BMP's, TGA's and PNG's.
  41.     */
  42.     class PEONMAIN_API SceneTexture : public IUnknown
  43.     {
  44.     protected:
  45.         /** OpenGL-specific texture handle */
  46.         GLuint m_tex;
  47.  
  48.     protected:
  49.         /** 
  50.         * Method to scan the surface at particular coordinates to
  51.         * grab the pixel data
  52.         * @param surface - SDL_Surface object to work with 
  53.         * @param x       - x coordinate 
  54.         * @param y       - y coordinate
  55.         * @return Uint32 - unsigned integer representing pixel info
  56.         */
  57.         Uint32 getPixel(SDL_Surface *surface, int x, int y);
  58.  
  59.     public:
  60.         /**
  61.         * Constructor
  62.         */
  63.         SceneTexture();
  64.  
  65.         /**
  66.         * Destructor
  67.         */
  68.         ~SceneTexture();
  69.  
  70.         /**
  71.         * This method loads the image into this object and
  72.         * gets everything correctly configured for use in the
  73.         * pipeline
  74.         * @param strFilename - filename of texture
  75.         * @param bAlpha - do we want the alpha channel?
  76.         * @param bMipMaps - do we want to create mipmaps?
  77.         * @param bRepeat - do we want to repeat this texture?
  78.         * @return bool - true if we're all ok
  79.         */
  80.         bool loadImage( const String& strFilename, bool bAlpha,
  81.             bool bMipMaps, bool bRepeat );
  82.  
  83.         /**
  84.         * This method just returns the handle to our texture data
  85.         * @return GLuint - texture data handle
  86.         */
  87.         GLuint getTex(){ return m_tex; }
  88.  
  89.     };
  90. }
  91.  
  92. #endif
  93.  
  94.